package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.RegionService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin("*")
@RequestMapping("/region")
public class RegionController {

    @Autowired
    private RegionService regionService;

    @GetMapping("/list")
    public Object listRegion(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit){
        IPage<DtsRegion> iPage = regionService.queryRegionAll(page, limit);
        long total = iPage.getTotal();
        List<DtsRegion> records = iPage.getRecords();
        Map<String,Object> data=new HashMap<>();
        data.put("total",total);
        data.put("items",records);
        return ResponseUtil.ok(data);
    }

}
